<template lang="html">
    <div class="bigThing">
        <myHeader>
            <div class="submit">
                <span @click="addEventType">确定</span>
            </div>
        </myHeader>
        <div class="content">
            <group>
                <datetime v-model="bigThing.time" format="YYYY-MM-DD HH:mm" @on-change="change" :title="'时间'" placeholder="请选择时间"></datetime>
            </group>
            <group>
                <x-textarea title="地点" v-model="bigThing.addr"  placeholder="请输入地点"></x-textarea>
            </group>
            <group>
                <x-textarea title="人物" placeholder="所有参加的人物" v-model="bigThing.members"></x-textarea>
            </group>
            <group>
                <x-input title="感受" placeholder="当时的感受（尽量详细的词语）" v-model="bigThing.feel"></x-input>
            </group>
            <group>
                <x-textarea title="发生事情" placeholder="发生了什么事情" v-model="bigThing.thingDetail"></x-textarea>
            </group>
            <group>
                <x-textarea title="情绪需求" placeholder="情绪的需求是什么" v-model="bigThing.emotionNeed"></x-textarea>
            </group>
        </div>
    </div>
</template>

<script>
import myHeader from '@/components/base/myHeader'
import { Datetime,Group,XAddress,ChinaAddressV4Data,XInput,XTextarea } from 'vux'
export default {
    components: {
        myHeader,
        Datetime,
        Group,
        XAddress,
        XInput,
        XTextarea
    },
    data(){
        return {
            bigThing: {},
            timePng: require('@/common/images/time.png'),
            addressPng: require('@/common/images/address.png'),
            feelPng: require('@/common/images/feel.png'),
            feelNeedPng: require('@/common/images/feel-need.png'),
            peoplePng: require('@/common/images/people.png'),
            thingsPng: require('@/common/images/things.png'),
            minuteListValue: '',
            ChinaAddressV4Data: ChinaAddressV4Data
        }
    },
    methods: {
        addEventType(){
            this.$api.post('/emotion/add', this.bigThing).then(res => {
                if (res) {
                    let text = '添加成功！'
                    if (this.bigThing['id']) {
                        text = '修改成功！'
                    }
                    this.$vux.toast.show({
                        text: text
                    })
                    this.$router.go(-1)
                }
            })
        },
        change(){

        }
    },
    created(){
        this.bigThing = {}
        if (this.$route.query.id) {
            this.$vux.loading.show({
                text: '加载中'
            })
            this.$api.get('/emotion/get-emotion-by-id', {
                id: this.$route.query.id
            }).then(res => {
                this.$vux.loading.hide()
                this.bigThing = res
            })
        }
    }
}
</script>

<style lang="scss" scoped>
    .bigThing{
        padding-bottom: 1rem;
        .submit{
            font-size: .16rem;
            text-align: right;
            padding-right: .1rem;
        }
    }
</style>
